package com.j2ee.JDKProxy.salary.supper;

import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class SalaryManagerTest {
	
	@Test
	public void testSalaryManager() {
		Object target = new SalaryManagerImpl() ;
		Logger logger = new Logger() ;
		Security security = new Security() ;
		privilege privilege = new privilege() ;
		Others others = new Others() ;
		List<Interceptor> interceptors = new ArrayList<>() ;
		interceptors.add(logger);
		interceptors.add(security) ;
		interceptors.add(privilege) ;
		interceptors.add(others) ;
		//创建拦截器对象
		SalaryInterceptor interceptor = new SalaryInterceptor(target, interceptors) ;
		//创建目标类代理对象
		SalaryManager salaryManager = (SalaryManager) Proxy.newProxyInstance(
				target.getClass().getClassLoader(), target.getClass().getInterfaces(), interceptor) ;
		salaryManager.showSalary() ;
	}
}
